
from trytond.pool import Pool, PoolMeta

__all__ = ['Purchase']
__metaclass__ = PoolMeta

class Purchase:
    __name__ = 'pcw.purchase'

    @classmethod
    def __setup__(cls):
        super(Purchase, cls).__setup__()
        cls._error_messages.update({
                'oris_date': "Error al verificar la fecha del movimiento. '%s'",
                })

    @classmethod
    def process(cls, orders):
        pool = Pool()
        Config = pool.get('oris.configuration')
        config = Config(1)
        for order in orders:
            date_res = config.verify_oris_date(order.date)
            if not date_res[0]:
                cls.raise_user_error('oris_date', error_args=(date_res[1],))

        super(Purchase, cls).process(orders)

